/*
Copyright 2007 Luke Benstead

This file is part of slMath.

slMath is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

slMath is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser Public License for more details.

You should have received a copy of the GNU Lesser Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

#ifndef VEC4_H_INCLUDED
#define VEC4_H_INCLUDED

#ifdef USE_DOUBLE_PRECISION
	typedef double slScalar;
#else
	typedef float slScalar;
#endif

struct slMat4;

#pragma pack(push)  /* push current alignment to stack */
#pragma pack(1)     /* set alignment to 1 byte boundary */

struct slVec4 {
	slScalar m_X;
	slScalar m_Y;
	slScalar m_Z;
	slScalar m_W;
};

#pragma pack(pop)


slVec4* slVec4Add(slVec4* pOut, const slVec4* pV1, const slVec4* pV2);

//
//slVec4* slVec4Cross(slVec4* pOut, const slVec4* pV1, const slVec4* pV2);


slScalar slVec4Dot(const slVec4* pV1, const slVec4* pV2);


slScalar slVec4Length(const slVec4* pIn);


slScalar slVec4LengthSq(const slVec4* pIn);

slVec4* slVec4Lerp(slVec4* pOut, const slVec4* pV1, const slVec4* pV2, slScalar t);
slVec4* slVec4Normalize(slVec4* pOut, const slVec4* pIn);

slVec4* slVec4Scale(slVec4* pOut, const slVec4* pIn, const slScalar s); ///< Scales a vector to length s

slVec4* slVec4Subtract(slVec4* pOut, const slVec4* pV1, const slVec4* pV2);

slVec4* slVec4Transform(slVec4* pOut, const slVec4* pV, const slMat4* pM);

slVec4* slVec4TransformArray(slVec4* pOut, unsigned int outStride,
			const slVec4* pV, unsigned int vStride, const slMat4* pM, unsigned int count);

bool 	slVec4AreEqual(const slVec4* p1, const slVec4* p2);

slVec4* slVec4Assign(slVec4* pOut, const slVec4* pIn);

#endif // VEC4_H_INCLUDED
